#ifndef __Switch_h
#define __Switch_h

#include <Arduino.h>

// define door action pin 4
#define SWITCH_ACTION_PIN 13

// The actions
typedef enum {
  SWITCH_OPEN = 1,  // 
  SWITCH_CLOSE = 0,   // 
} 
SwitchActions;

// callback function
#if defined(ESP8266) || defined(ESP32)
#include <functional>
#define SWITCH_CALLBACK_SIGNATURE std::function<void(unsigned int)> callback
#else
#define SWITCH_CALLBACK_SIGNATURE void (*callback)(unsigned int)
#endif

class Switch
{

public:
    Switch(); //构造函数
    void setup();
    void loop();
    void open(); // 开启
    void close(); // 关闭
    int getValue();
    Switch& setCallback(SWITCH_CALLBACK_SIGNATURE);

private:
    SWITCH_CALLBACK_SIGNATURE;
    // SwitchActions action = SWITCH_CLOSE;
    int status;
};

#endif